const { checkUserCollected } = require("../service/collect.service")
const { getListById } = require("../service/list.service")

class DetailController {
  // 获取详情信息
  async getDetail(ctx, next) {
    const { id } = ctx.query
    // 获取详情
    const res = await getListById(id)
    // 是否收藏
    const collected = await checkUserCollected(id, ctx.user.id)
    ctx.body = {
      status: 200,
      data: {
        listDeatil: res,
        collected: collected.length ? true : false
      }
    }
  }
}

module.exports = new DetailController()